
************************************************************************************************************************************************
****************************** REPLICATION CODE: RELIGION AND BRAZILIAN POLITICS 
****************************** 2019. Cambridge University Press
****************************** By Amy Erica Smith (amyericas@gmail.com) 

****************************** ANALYSIS OF CHURCHES NORTH AND SOUTH CONGREGANT SURVEY



****************************************** VARIABLE CODING **************************************************************************************
use "ChurchesNorthAndSouth_Brazil2014.dta", clear

recode p3_ p4_ (7=5)
foreach i in p3_ p4_ p6_ p7_ p8_ p9_ p10_ p11_ p12_ p13_ p14_ p15_ p16_ p17_ p18_ p19_ p20_ p21_ p22_ p23_ {
	replace `i' = (`i'-1)/4
} 


**************************************** variables for location ***************************************
recode igreja (1=6) (6=9) (9=1), g(site2)
replace site2 = 10+communitylocation if site2 == .
egen site = group(site2) if site != 7
drop if site == . // DROP ONE CHARISMATIC COMMUNITY WITH VERY FEW MEMBERS, WITH ONLY 7 INTERVIEWEES
drop site2
lab def site 1 "Catholic 1" 2 "Catholic 2" 3 "Catholic 3" 4 "Catholic 4" 5 "Protestant 1" ///
	6 "Protestant 2" 7 "Pentecostal 1" 8 "Pentecostal 2" 9 "Community Site 1" ///
	10 "Community Site 2" 11 "Community Site 3" 12 "Community Site 4" 13 "Community Site 5", modify
lab val site site
xtset site

clonevar site2 = site
recode site2 (9/13=9)
lab def site2 1 "Cath 1" 2 "Cath 2" 3 "Cath 3" 4 "Cath 4" 5 "Prot 1" ///
	6 "Prot 2" 7 "Pent 1" 8 "Pent 2" 9 "Community Sites" , modify
lab val site2 site2


egen numinsite = count(site), by(site)
g weight_50 = 50/numinsite


recode site (1 2 3 4 = 1) (5 6 7 8 = 2) (9 10 11 12 13 = 3), g(interviewlocation)
	lab def interviewlocation 1 "Catholic" 2 "Evangelical/Pentecostal" 3 "Non-Church Site"
	lab val interviewlocation interviewlocation
g churchsite = interviewlocation == 1 | interviewlocation == 2
	lab var churchsite "Interviewed at Church"
g catholicsite = interviewlocation == 1 
	lab var catholicsite "Interviewed at Catholic Church"
g evangelicalsite = interviewlocation == 2 
	lab var evangelicalsite "Interviewed at Evan./Pent. Church"

g relig = interviewlocation
	replace relig = 1 if churchtype == 1
	replace relig = 2 if churchtype == 2 | churchtype == 3
	replace relig = 4 if churchtype == 5 | churchtype == 7
	lab def relig 1 "Catholic" 2 "Evangelical/Pentecostal" 3 "No Religion" 4 "Other Religion"
	lab val relig relig
nicelylabelleddummies relig, g(relig)
*********************************************************************************************************


*************************************** neighborhood info ************
g bairro = "A" if site == 2 | site == 6 | site == 10
replace bairro = "B" if site == 4
replace bairro = "C" if site == 5 | site == 7
replace bairro = "D" if site == 11
replace bairro = "E" if site == 1 | site == 3 | site == 9
replace bairro = "F" if site == 8
replace bairro = "G" if site == 13
replace bairro = "H" if site == 12

egen ses = rowmean(p35_educ p36_inc)
egen siteeduc = mean(p35_educ), by(site)
	summ siteeduc 
	replace siteeduc = (siteeduc-r(min))/(r(max)-r(min))
egen siteinc = mean(p36_income), by(site)
	summ siteinc 
	replace siteinc = (siteinc-r(min))/(r(max)-r(min))
egen siteses = mean(ses), by(site)
	summ siteses 
	replace siteses = (siteses-r(min))/(r(max)-r(min))


***********************************	EXPOSURE TO POLITICAL STUFF IN CHURCH
replace p28_elections_church = (3-p28_elections_church)/2
foreach i in p30_encouragevote_church p31_encouragereflection_church p32_candidate_church {
	replace `i' = `i' - 1
}
replace p32_candidate_church = . if site > 8 // REMOVES SOME NON-CHURCH SITES WHERE THIS IS FOR SOME REASON NON-MISSING

replace p32c_churchcand_deputado = 1 if p32b_ == "Candidatos Catolicos" | p32b_ == "Eros Biondine" | p32b_ == "Noraldino" ///
		| p32b_ == "Noraldino e Walter Tosta" | p32b_ == "Pastor Carlos Henrique" | p32b_ == "Pastor Carlos Henrique e Pastor George Hilton"
	recode p32c_churchcand_deputado (.=0) if p32_candidate_church < .
replace p32c_churchcand_pres = 1 if p32b_ == "Dilma" | p32b_ == "Marina" | p32b_ == "Marina e Pastor Everaldo" | p32b_ == "Pastor everaldo"
	recode p32c_churchcand_pres (.=0) if p32_candidate_church < .
g p32c_churchcand_unspecified = (p32_candidate_church == 1 & p32c_churchcand_pres == 0 & p32c_churchcand_deputado == 0) if  p32_candidate_church < .

alpha p30_encouragevote_church p31_encouragereflection_church
alpha p28_elections_church p32_candidate_church
factor p28_ p30_ p31_ p32_
corr p28_ p30_ p31_ p32_
g encouragevoting_church = (p30_ + p31_)/2 
egen politicking_church = rowmean(p28_ p32_)

recode p28_ (0/.5=0) (1=1), g(electiontalk_dichot)

***** church-level measures
egen church_electiontalk = mean(p28_elections_church), by(igreja)
egen church_encouragevoting = mean(encouragevoting_church), by(igreja)
egen church_candidatesupport = mean(p32_candidate_church), by(igreja)
preserve
	collapse   siteses church_electiontalk church_encouragevoting church_candidatesupport, by(igreja)
	tab1  siteses church_electiontalk church_encouragevoting church_candidatesupport
	corr  siteses church_electiontalk church_encouragevoting church_candidatesupport
	alpha church_electiontalk church_encouragevoting church_candidatesupport, item
restore
egen church_politicking = rowmean(church_electiontalk church_encouragevoting church_candidatesupport)


***********************************	CHURCH ENGAGEMENT AND RELIGIOUS BELIEFS
lab var p7_ "Fear of God's Wrath"

replace p5_bibliteralism = (p5_ - 1)/2
	lab var p5_ "Biblical Literalism"
	
egen doctrinalconservatism = rowmean(p5_ p7_)

g freqchurch = (6-p1_)/5
g freqactivities = (6-p2_)/5
	replace freqactivities = 0 if freqactivities == .
g concentrationfriends = p3_/p4_
		replace concentrationfriends = 0 if p3_ == 0 & concentrationfriends == .
		replace concentrationfriends = 0 if p3_ == .
		replace concentrationfriends = concentrationf
g logconcentration = log(concentrationfriends)
	summ logconcentration
	replace logconcentration = (logconcentration-r(min))/(r(max)-r(min))
	replace logconcentration = 0 if concentrationfriends == 0

factor freqchurch freqactivities logconcentration
	summ freqchurch freqactivities logconcentration
egen churchengagement = rowmean(freqchurch freqactivities logconcentration)
	lab var churchengagement "Church Networks and Engagement"
recode churchengagement (0/.59999=0)(.6/1=1), g(engaged)
	
egen sociability = rowmean(p3_ p4_)

******************************************** POLITICAL ENGAGEMENT
replace p24_vote_prob = (4-p24_vote_prob)/3
replace p27_freqnews = (5-p27_freqnews)/4
* duty to vote: p17_voteduty
egen voting = rowmean(p24_ p17_)

recode p25_vote_candidate (1/4 7/9 = 1) (5 6 . .b = 0), g(hascandidate)

recode p33_candidate_nonchurch (1=0) (2/4=1)

******************************************** POLITICAL BELIEFS AND LEGITIMACY
g genderroles = 1-p16_genderrolesdiff
factor genderroles p18_policy_gaymarriage p19_policy_abortion 
	alpha genderroles p18_policy_gaymarriage p19_policy_abortion 
egen sexualliberalism = rowmean(genderroles p18_policy_gaymarriage p19_policy_abortion) //LOW ALPHA COEFFICIENT, AND DOESN'T SEEM TO WORK IN MODELS
g sexualtraditionalism = 1-sexualliberalism

lab var p9_ "Legitimacy of Political System"
g statesecularism = 1-p23_
lab var statesecularism "Support for Secular State"
recode statesecularism (0/.5 = 0) (.51/1 = 1), g(highsecularism)
	
lab var p8_ "Support for Democracy"
recode p8_ (0/.75 = 0) (1=1), g(highdemlegit)

********************************************* VALUES: these measures suck
summ p10_values_authority p11_values_loyalty p12_values_sanctity p13_values_care p14_values_equality p15_values_fairness 
tab1 p10_values_authority p11_values_loyalty p12_values_sanctity p13_values_care p14_values_equality p15_values_fairness 
factor p10_values_authority p11_values_loyalty p12_values_sanctity p13_values_care p14_values_equality p15_values_fairness 
corr p16_genderrolesdiff p10_values_authority p11_values_loyalty p12_values_sanctity p13_values_care p14_values_equality p15_values_fairness 
egen bindingvalues = rowmean(p10_values_authority p11_values_loyalty p12_values_sanctity)
egen universalizingvalues = rowmean(p13_values_care p14_values_equality p15_values_fairness )


********************************************* DEMOGRAPHICS
g woman = sexo-1
	
foreach i in p35_educ p36_income {
	replace `i' = (`i'-1)/5
}

g age = 2014-p34_yearborn
recode age (14/25 = 1) (26/35 = 2) (36/45 = 3) (46/55 = 4) (56/65 = 5) (66/100 = 6), g(agegroup)
g under26 = agegroup == 1
recode age (14/25 = 1) (26/40 = 2) (41/59 = 3) (60/100 = 4), g(agegroup2)
	replace agegroup2 = (agegroup2-1)/3

********************************************* MERGE IN CLERGY-LEVEL DATA!!!
preserve
use "C:\Users\aesmith2\Dropbox\Work\Data\2014 field work Brazil and US\Data\Public Files\ChurchesNorthAndSouth_Brazil2014_Clergy.dta", clear
	sencode city, replace
	g juiz = city == 2
	g conference = city == 1
g idnum = city*10000+qnrnum1
g site2 = 1 if idnum == 20205 | idnum == 20206 | idnum == 20320
	replace site2 = 2 if idnum == 20223 | idnum == 20224
	replace site2 = 3 if idnum == 20303 
	replace site2 = 5 if idnum == 20331 | idnum == 20332 | idnum == 20333
	replace site2 = 6 if idnum == 20304
	replace site2 = 7 if idnum == 20207 | idnum == 20208 | idnum == 20330
	replace site2 = 8 if idnum == 20105
drop if site2 == .
********** TREATMENT/VERSION VARIABLES
g versionA = (version == "A")
g versionB = (version == "B")
g versionC = (version == "C")
	replace versionC = . if conference == 0
	replace versionA = . if versionC == 1
destring p4_weeklyattend, replace
replace p35_clergyviewdiff_nbhd = "." if p35_clergyviewdiff_nbhd == "Don't Know" | p35_clergyviewdiff_nbhd == "Don't know" 
replace p33_samediffcand = "." if p33_samediffcand == "Don't know" 
destring p35_clergyviewdiff_nbhd, replace
destring p33_samediffcand, replace
egen weeklyattend = cut(p4_weeklyattend), group(10)
replace weeklyattend=weeklyattend/9
recode p5_weeklyattend_chg (1=1) (2=0) (3 . =.5), g(attendance)
g attendrise = (p5_weeklyattend_chg == 1)
recode p6_ (1=1) (2/. = 0) if versionC != 1, g(outreach)
recode p7_worryotherchurches 5=.
	replace p7_worryotherchurches = (3-p7_worryotherchurches)/2
	recode p7_worry (0 = 0) (.5 1 = 1), g(worrydummy)
	g noworry = 1-worrydummy
alpha attendrise outreach noworry, item
egen growthoriented = rowmean(attendrise outreach)
	recode growthoriented (.5=0)
**** GRIEVANCES and the fairness of laws
recode p36_favorgroup (2=1) (1 3 =0), g(grievancelaws2)
recode p37_favorgroup (2=1) (1 3 =0) (4 5 6 = .), g(grievancepres2)
recode p36_favorgroup (3=1) (1 2 =0), g(neutrallaws)
recode p37_favorgroup (4 5 6 3=1) (1 2 =0), g(neutralpres)
egen grievances2 = rowmean(grievancelaws2 grievancepres2)
egen stateneutrality = rowmean(neutrallaws neutralpres)
********************** RECODING 4-POINT and 3-point VARIABLES ON 0 TO 1 SCALE
forvalues i = 8/27 {
	replace p`i'_ = (p`i'_-1)/4
}
forvalues i = 38/39 {
	replace p`i'_ = (p`i'_-1)/4
}
recode  p28_campn_members 5 = .
foreach i in 28 29 30 31 34 35 {
	replace p`i'_ = (p`i'_-1)/3
}
egen electoralactivism = rowmean(p29_campn_encourageturnout p30_campn_faithvote p31_campn_leaders)
***** SIMILARITY TO CHURCH/NEIGHBORHOOD; DIVERSITY WITHIN CHURCH
recode p33_samediffcand (1=0) (2 3 = 1) (4 = .)
replace p34_clergyviewdiff_church = 1-p34_clergyviewdiff_church 
egen difference = rowmean(p34_ p33_)
***** CONSERVATIVE TEACHINGS
global conservativeteachings p15_discuss_godswrath p16_discuss_endtimes p20_discuss_avoidsin ///
		p21_discuss_traditionalfamily p22_discuss_chastity p23_discuss_homosexuality p24_discuss_abortion 
egen conservatism = rowmean($conservativeteachings)
	summ conservatism 
	replace conservatism = (conservatism-r(min))/(r(max)-r(min))
collapse conservatism p23_discuss_homosexuality p24_discuss_abortion p25_discuss_environment p26_discuss_racism p19_discuss_ministerpoor ///
		electoralactivism weeklyattend growthoriented p29_campn_encourageturnout p30_campn_faithvote p31_campn_leaders difference ///
		grievances2 stateneutrality p38_legit_system p39_legit_democracy, ///
		by(site2)
rename conservatism clergy_conservatism 
rename p23_discuss_homosexuality clergy_gay
	replace clergy_gay = 1-clergy_gay
rename p24_discuss_abortion clergy_abortion
	replace clergy_abortion = 1-clergy_abortion
rename p25_discuss_environment clergy_env
rename p26_discuss_racism clergy_racism
rename p19_discuss_ministerpoor clergy_poor
rename electoralactivism clergy_electoralactivism 
rename weeklyattend cong_weeklyattend
rename growthoriented cong_growth
rename difference cong_diversity
rename p29_campn_encourageturnout clergy_turnout
rename p30_campn_faithvote clergy_conscientious
rename p31_campn_leaders clergy_candidate
rename grievances clergy_harm
rename stateneutrality clergy_stateneutrality
rename p38_legit_system clergy_legit
rename p39_legit_democracy clergy_democracy

summ clergy_electoralactivism 
replace clergy_electoralactivism = (clergy_electoralactivism-r(min))/(r(max)-r(min))

egen clergy_civic = rowmean(clergy_turnout clergy_conscientious)

g clergy_harm2 = 1-clergy_stateneutrality
egen clergy_grievances = rowmean(clergy_harm clergy_harm2)
recode clergy_grievances (0 = 0) (.25/.5=1), g(clergy_grievances2)
recode clergy_grievances (0/.25 = 0) (.26/.5=1), g(clergy_grievances3)

tempfile clergydata
save `clergydata', replace
restore
merge m:1 site2 using `clergydata'
	drop _merge
********************************************* finish MERGE IN CLERGY-LEVEL DATA
	
***************** LAAKSO-TAAGEPERA INDEX
recode p25_ (5 6 = .), g(vote)
tab vote, g(vote)
forvalues i = 1/7 {
	egen num_vote`i' = total(vote`i'), by(site2)
}
egen num_allvote = rowtotal(num_vote*)
forvalues i = 1/7 {
	g prop_vote`i' = (num_vote`i'/num_allvote)^2
}
egen denominator = rowtotal(prop_vote*)
g laakso_taag2 = 1/denominator
	summ laakso_taag2
	g laakso_taag = (laakso_taag-r(min))/(r(max)-r(min))
drop vote* num_* prop_* denominator

egen cong_diversity2 = rowmean(laakso_taag cong_diversity)





************************************************************************************************************************************************
************************************************************************************************************************************************
****************************************** ANALYSIS ********************************************************************************************

************ FIGURE 3.2. Religious Characteristics of the Congregations
preserve
tab p5_bibliteralism, g(p5_)
graph bar p5_3 p5_2 p5_1 , over(site2, label(labsize(small))) stack percentage ///
	bar(1, lcolor(black) fcolor(gs15)) ///
	bar(2, lcolor(black) fcolor(gs10)) ///
	bar(3, lcolor(black) fcolor(gs5)) ///
	blabel(bar, size(vsmall) position(center) format(%3.1f)) ///
	graphregion(fcolor(white) lcolor(white)) ytitle("Interpretation of Bible" "(Percentage)", margin(small)) xsize(6) ///
	legend(order(1 "God's" "literal word" 2 "Divinely" "inspired" 3 "Ancient" "book") col(3) symxsize(5) span size(small)) name(bible, replace)
collapse (mean) mn1=p6_godslove mn2=p7_godswrath ///
	(semean) se1=p6_godslove se2=p7_godswrath, by(site2)
drop if site2 == .
set obs 26
egen denom = seq(), f(1) t(9) block(1)
	lab val denom site2
	drop site2
egen dv = seq(), f(1) t(3) block(9)
sort denom dv
g xaxis = _n
foreach i in mn1 mn2 se1 se2 {
	egen `i'mn = mean(`i'),by(denom)
	replace `i' = `i'mn
	drop `i'mn
}
g dv_val = mn1 if dv == 1
	replace dv_val = mn2 if dv == 2
g se_val = se1 if dv == 1
	replace se_val = se2 if dv == 2
g lb = dv_val-2*se_val
g ub = dv_val+2*se_val
graph twoway (bar dv_val xaxis if dv == 1, lcolor(black) fcolor(gs7)) || ///
			(bar dv_val xaxis if dv == 2, lcolor(black) fcolor(gs13)) || ///
			(rspike ub lb xaxis, lcolor(black)), ///
		legend(order(1 "Feel God's Love" 2 "Fear God's Wrath") cols(2) symxsize(5) span  size(small)) ///
		xlabel(1.5 "Cath 1" 4.5 "Cath 2" 7.5 "Cath 3" 10.5 "Cath 4" 13.5 "Prot 1" ///
				16.5 "Prot 2" 19.5 "Pent 1" 22.5 "Pent 2" 25.5 "Community Sites", notick labsize(small)) ///
		xtitle("") ylabel(.25(.25)1) ytitle("Agreement (0-1 Scale)", margin(medium)) graphregion(fcolor(white) lcolor(white)) ///
		caption("Source: Churches North and South 2014, Congregational Study." ///
			"Whiskers represent 95% confidence intervals.", span size(small)) ///
		xsize(6) name(lovewrath, replace)
restore
graph combine bible lovewrath, col(1) graphregion(fcolor(white) lcolor(black)) ysize(6)
************ END FIGURE 3.2. Religious Characteristics of the Congregations


************ CHAPTER 6 EXPLORATION: POLICY VIEWS OF PEOPLE IN COMUNIDADE IRMAOS NO MESTRE JESUS, AND DIFFS BETWEEN EVANGELICALS AND CATHOLICS ON ABORT/GAY
*** redo "Setup_JF2014," without dropping the Comunidade
tabstat p18_ p19_ if igreja == 7, statistics(mean semean)
g diff_abortion_gm = abs(p19_ - p18_)
tabstat diff_abortion_gm, by(relig)
ologit diff_abortion_gm i.relig
************ END CHAPTER 6 EXPLORATION: POLICY VIEWS OF PEOPLE IN COMUNIDADE IRMAOS NO MESTRE JESUS, AND DIFFS BETWEEN EVANGELICALS AND CATHOLICS ON ABORT/GAY


************ FIGURE 6.3. POLICY VIEWS, JF 2014
preserve
collapse (mean) mn1=p23_policy_prochristian mn2=p16_genderrolesdiff mn3=p18_policy_gaymarriage mn4=p19_policy_abortion ///
				mn5=p20_policy_environ mn6=p21_policy_antiracism mn7=p22_policy_antipoverty ///
		(semean) se1=p23_policy_prochristian se2=p16_genderrolesdiff se3=p18_policy_gaymarriage se4=p19_policy_abortion ///
				se5=p20_policy_environ se6=p21_policy_antiracism se7=p22_policy_antipoverty , by(site2)
set obs 69
egen denom = seq(), f(1) t(10) block(1)
	lab val denom site2
	drop site2
egen dv = seq(), f(1) t(7) block(10)
g xaxis = _n
g mn_val = .
g se_val = .
forvalues i = 1/7 {
foreach stat in mn se {
	egen `stat'`i'mn = mean(`stat'`i'),by(denom)
	replace `stat'_val = `stat'`i'mn if dv == `i'
	drop `stat'`i'mn
	}
}
rename mn_val dv_val
g lb = dv_val-2*se_val
g ub = dv_val+2*se_val
replace lb = 0 if lb < 0
replace ub = 1 if ub > 1
graph twoway (scatter dv_val xaxis if denom < 5, mcolor(black) msymbol(X)) || ///
			(scatter dv_val xaxis if denom == 5 | denom == 6, mcolor(gs8) msymbol(Th)) || ///
			(scatter dv_val xaxis if denom == 7 | denom == 8, mcolor(black) msymbol(D)) || ///
			(scatter dv_val xaxis if denom == 9, mcolor(black) msymbol(Oh)) || ///
			(rspike ub lb xaxis, lcolor(black)), ///
		legend(order(1 "Catholic" "Congregations" 2 "Evangelical" "Congregations" ///
				3 "Pentecostal" "Congregations" 4 "Community" "Sites") cols(4) symxsize(5) span  size(small)) ///
		xlabel(5 "Recognize Christianity" 15 "Different Gender Roles" 25 "Same-Sex Marriage" 35 "Abortion" 45 "Environment" 55 "Anti-Racism" ///
				65 "Anti-Poverty", notick labsize(small)) ///
		xtitle("") ylabel(0 "Strongly Disagree" .25 .5 .75 1 "Strongly Agree", angle(horizontal)) ///
		ytitle("Agreement") graphregion(fcolor(white) lcolor(black)) ///
		caption("Source: Churches North and South 2014, Congregational Study. Whiskers represent 95% confidence intervals.", span size(small)) ///
		xsize(6.5) xline(10 20 30 40 50 60, lcolor(gs10) lwidth(thin))
restore
************ END FIGURE 6.3. POLICY VIEWS, JF 2014


*********** FIGURE 6.4. DETERMINANTS OF DIVERGING FROM CHURCH OPINION, JF 2014
preserve
global dvs p16 p18 p19  
global results ""
eststo clear
foreach i in $dvs {
tempfile file_`i'
xtreg `i' b2.relig i.igreja if igreja < .
	predict `i'_resid, e 
		replace `i'_resid = (`i'_resid)^2
xtreg `i'_resid freqactivities freqchurch doctrinalconservatism statesecularism woman p35_ p36_ b2.relig 
	parmest, saving(`file_`i'', replace) idstr(`i') flist(results) level(90)
}
dsconcat $results
drop if parm == "_cons" | parm == "2b.relig"
rename idstr dv
	sencode dv, replace
	lab def dv 1 "Different Gender Roles" 2 "Same-Sex Marriage" 3 "Abortion", modify
	lab val dv dv
sencode parm, replace
	replace parm = 9-parm
	lab def parm 8 "Frequency of Church Activities" 7 "Frequency of Worship Service" 6 "Doctrinal Conservatism" ///
			5 "Support for Secular State" 4 "Woman" ///
			3 "Education" 2 "Income" 1 "Catholic Congregation", modify
	lab val parm parm
graph twoway (scatter parm estimate , mcolor(black)) ///
			(rspike min90 max90 parm, lcolor(black) horizontal), ///
	by(dv, col(3) xrescale graphregion(fcolor(white) lcolor(black)) legend(off) ///
		note("Coefficients represent impact of each variable on divergence from congregational" ///
			"opinion. Estimates and 90% confidence intervals from hierarchical models regressing" ///
			"squared residuals from first-stage hierarchical models of congregational opinion." ///
			"Source: Churches North and South 2014, Congregational Study.", size(small) margin(medium) span) ) ///
	xtitle("") ytitle("") ylabel(1(1)8, valuelabel angle(horizontal) labsize(small)) xlabel(#3) ///
	subtitle(, lcolor(white) fcolor(white)) ///
	plotregion(lcolor(black)) xline(0, lcolor(gs8)) xsize(5) 
restore
*********** END FIGURE 6.4. DETERMINANTS OF DIVERGING FROM CHURCH OPINION, JF 2014


*********** FIGURE 7.1. Variation in Messages, JF 2014
preserve
drop if site2 > 8
recode p30_encouragevote_church p31_encouragereflection_church p32_candidate_church electiontalk_dichot (1=100)
collapse (mean) mn1=p30_encouragevote_church mn2=p31_encouragereflection_church mn3=p32_candidate_church mn4=electiontalk_dichot  ///
		(semean) se1=p30_encouragevote_church se2=p31_encouragereflection_church se3=p32_candidate_church se4=electiontalk_dichot , by(site2)
set obs 35
egen denom = seq(), f(1) t(9) block(1)
	lab val denom site2
	drop site2
egen dv = seq(), f(1) t(4) block(9)
g xaxis = _n
g mn_val = .
g se_val = .
forvalues i = 1/4 {
foreach stat in mn se {
	egen `stat'`i'mn = mean(`stat'`i'),by(denom)
	replace `stat'_val = `stat'`i'mn if dv == `i'
	drop `stat'`i'mn
	}
}
rename mn_val dv_val
g lb = dv_val-2*se_val
g ub = dv_val+2*se_val
replace lb = 0 if lb < 0
replace ub = 100 if ub > 100
graph twoway (scatter dv_val xaxis if denom < 5, mcolor(black) msymbol(X)) || ///
			(scatter dv_val xaxis if denom == 5 | denom == 6, mcolor(gs8) msymbol(Th)) || ///
			(scatter dv_val xaxis if denom == 7 | denom == 8, mcolor(black) msymbol(D)) || ///
			(rspike ub lb xaxis, lcolor(black)), ///
		legend(order(1 "Catholic" "Congregations" 2 "Evangelical" "Congregations" 3 "Pentecostal" "Congregations") ///
				cols(4) symxsize(5) span  size(small)) ///
		xlabel(4.5 "Leaders Encourage Turnout" 13.5 "Leaders Encourage Conscientious Voting" 22.5 "Leaders Support Candidate" ///
				31.5 "Congregant Discussion of Election", notick labsize(small)) ///
		xtitle("") ylabel(0(20)100) ytitle("Percentage Reporting", margin(small)) graphregion(fcolor(white) lcolor(black)) ///
		caption("Source: Churches North and South 2014, Congregational Study. Whiskers represent 95% confidence intervals.", span size(vsmall)) ///
		xsize(5) xline(9 18 27, lcolor(gs10) lwidth(thin))
restore
*********** END FIGURE 7.1. Variation in Messages, JF 2014


****************************** CHAPTER 7, FIGURE NOT SHOWN: Laakso-Taager
preserve
collapse p23_ laakso_taag cong_diversity clergy_electoralactivism clergy_candidate clergy_conservatism doctrinalconservatism cong_growth clergy_civic, by(site2)
pwcorr p23_ laakso_taag clergy_electoralactivism clergy_candidate clergy_conservatism doctrinalconservatism cong_growth clergy_civic, sig
graph twoway (lfitci laakso_taag doctrinalconservatism, lcolor(black) lwidth(thick) fcolor(gs15) alcolor(gs14) alwidth(medium)), ///
	graphregion(fcolor(white) lcolor(black)) legend(off) text(.2 .63 "r = .93" "N = 8") ///
	ytitle("Fragmentation of Vote in Congregation" "(Laakso-Taagepera Index, rescaled 0-1)", margin(medium)) ///
	xtitle("Mean Doctrinal Conservatism of Congregants", margin(medium)) ///
	note("Source: Juiz de Fora Churches North and South, 2014.")
restore
****************************** CHAPTER 7, FIGURE NOT SHOWN: Laakso-Taager


****************************** FIGURE 8.1: Variation in Legitimacy and State Secularism, JF 2014
preserve
collapse (mean) mn1=p8_democracy mn2=p9_polsystem ///
		(semean) se1=p8_democracy se2=p9_polsystem, by(site2)
set obs 19
egen denom = seq(), f(1) t(10) block(1)
	lab val denom site2
	drop site2
egen dv = seq(), f(1) t(2) block(10)
g xaxis = _n
g mn_val = .
g se_val = .
forvalues i = 1/2 {
foreach stat in mn se {
	egen `stat'`i'mn = mean(`stat'`i'),by(denom)
	replace `stat'_val = `stat'`i'mn if dv == `i'
	drop `stat'`i'mn
	}
}
rename mn_val dv_val
g lb = dv_val-2*se_val
g ub = dv_val+2*se_val
replace lb = 0 if lb < 0
replace ub = 1 if ub > 1
graph twoway (scatter dv_val xaxis if denom < 5, mcolor(black) msymbol(X)) || ///
			(scatter dv_val xaxis if denom == 5 | denom == 6, mcolor(gs8) msymbol(Th)) || ///
			(scatter dv_val xaxis if denom == 7 | denom == 8, mcolor(black) msymbol(D)) || ///
			(scatter dv_val xaxis if denom == 9, mcolor(black) msymbol(Oh)) || ///
			(rspike ub lb xaxis, lcolor(black)), ///
		legend(order(1 "Catholic" "Congregations" 2 "Evangelical" "Congregations" 3 "Pentecostal" "Congregations" 4 "Community" "Sites") ///
				cols(4) symxsize(5) span  size(small)) ///
		xlabel(5 "Support for Democracy" 15 "Legitimacy of Political System", notick labsize(small)) ///
		xtitle("") ylabel(0 "Strongly Disagree" .25 .5 .75 1 "Strongly Agree", angle(horizontal)) ///
		ytitle("Level of Support", margin(small)) graphregion(fcolor(white) lcolor(black)) plotregion(lcolor(black)) ///
		caption("Source: Churches North and South 2014, Congregational Study. Whiskers represent 95% confidence intervals.", span size(vsmall)) ///
		xline(10, lcolor(gs10) lwidth(thin))
restore
****************************** END FIGURE 8.1: Variation in Legitimacy and State Secularism, JF 2014


******************** FIGURE 8.2. Determinants of Democratic and System Attitudes, jf 2014
preserve
global results ""
foreach dv in p8_ p9_ {
	tempfile tf`dv'
	xtreg `dv' clergy_stateneutrality clergy_democracy churchengagement doctrinalconservatism statesecularism i.relig ///
			p35_ p36_ woman agegroup2 if churchsite == 1
	parmest, saving(`tf`dv'', replace) idstr(`dv') flist(results) level(90)
}
clear
append using $results
drop if parm == "_cons" | parm == "1b.relig"  
sencode idstr, replace
	rename idstr dv
	lab def dv 1 "Democratic Legitimacy" 2 "Legitimacy of Political System" 
	lab val dv dv
g xxx = 11-_n if _n < 11
sencode parm, replace gsort(xxx)
	lab def parm 10 "Clergy Perception of State Neutrality" 9 "Clergy Support for Democracy" 8 "Church Engagement/Networks (Individual)" ///
		7 "Doctrinal Conservatism (Individual)" 6 "Support for Secular State (Individual)" ///
		5 "Evangelical" 4 "Educational Level" 3 "Income" 2 "Woman" 1 "Age Group" , modify
	lab val parm parm
	drop xxx
graph twoway (scatter parm estimate, mcolor(black)) ///
			(rspike min90 max90 parm, lcolor(black) horizontal), ///
	by(dv, col(2) graphregion(fcolor(white) lcolor(black))	legend(off) ///
		note("Source: Juiz de Fora Churches North and South 2014, Citizen Study" ///
			"Coefficients and 90% confidence intervals from hierarchical models. N=364." ) 	) ///
	ylabel(1(1)10, valuelabel angle(horizontal) labsize(small)) plotregion(lcolor(black)) xlabel(-0.5(0.25)0.5) ///
	ytitle("") xline(0, lcolor(gs10)) xsize(6.5)	
restore
******************** END FIGURE 8.2. Determinants of Democratic and System Attitudes



